import time

from selenium.webdriver.common.by import By


class Loan:
    def loan_admin(self,  driver, username, password):
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "login_btn").click()
        driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[5]/a").click()
        driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[5]/ul/li[1]/a").click()
        driver.find_element(By.XPATH,
                                    "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr/td[7]/button[1]").click()
        time.sleep(2)
        driver.find_element(By.XPATH, "/html/body/div[2]/div[2]/div/div/div/div/div/div/div/div[4]/button[1]").click()
    def loan_1(self, driver, username, password, money, loantime):
        driver.find_element(By.ID, "username").send_keys(username)
        driver.find_element(By.ID, "password").send_keys(password)
        driver.find_element(By.ID, "login_btn").click()
        driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[3]/a").click()
        driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[3]/ul/li[2]/a").click()
        driver.find_element(By.XPATH, "/html/body/div/div/main/div/div/div/div/div[2]/div/form/div[1]/input").send_keys(money)
        driver.find_element(By.XPATH, "/html/body/div/div/main/div/div/div/div/div[2]/div/form/div[3]/input").send_keys(loantime)
        driver.find_element(By.XPATH, "/html/body/div/div/main/div/div/div/div/div[2]/div/form/div[4]/button").click()
        time.sleep(2)
        driver.find_element(By.XPATH, "/html/body/div[2]/div[2]/div/div/div/div/div/div/div/div[4]/button[1]").click()